<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>投诉列表</title>
	<link rel="stylesheet" type="text/css" href="../common/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../common/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../common/demo.css">
	<script type="text/javascript" src="../common/jquery.min.js"></script>
	<script type="text/javascript" src="../common/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../common/common.js"></script>
	<script type="text/javascript" src="../common/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>

<table id="dg" title="投诉列表" style="width: 99%;height:630px"
	   data-options="rownumbers:true,
						singleSelect:true,
						autoRowHeight:true,
						pagination:true,
						pageSize:20,
						url:'/manage/complain/list',
						method:'get',
						toolbar:'#tb'">
	<thead>
	<tr>
		<th data-options="field:'id',width:100,hidden:'true'">id</th>
		<th data-options="field:'info',width:100">投诉内容</th>
		<th data-options="field:'createTime',width:190,align:'center',
					formatter: function (createTime, row, index) {
			       var datetime = dateFormatter(createTime); <!--value就是数据库具体的值-->
			       return datetime;
			    }">提交时间</th>
		<th data-options="field:'state',width:100,
					formatter: function (state, row, index) {
			       return deletedState(state); <!--value就是数据库具体的值-->
			    }">反馈状态</th>
		<th data-options="field:'result',width:100">处理结果</th>
	</tr>
	</thead>
</table>
<div id="tb" style="padding:2px 5px;">
	反馈状态:
	<select id="state" class="easyui-combobox" panelHeight="auto" style="width:100px">
		<option value="">全部</option>
		<option value="0">处理中</option>
		<option value="1">已解决</option>
	</select>
	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="searchA()">Search</a>
</div>

<div id="approve" class="easyui-window" title="编辑" data-options="iconCls:'icon-save'" style="width:500px;height:400px;padding:10px;">
	<div class="easyui-panel" title="投诉编辑" style="width:100%;max-width:400px;padding:30px 60px;">
		<form id="update" method="post">
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" name="id" style="width:100%" data-options="label:'投诉编号id:',required:false" readonly="readonly">
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" name="info" style="width:100%" data-options="label:'投诉内容:',required:false" readonly="readonly">
			</div>
			<div style="margin-bottom:20px">
				<input class="easyui-textbox" name="result" style="width:100%" data-options="label:'处理结果:',required:true">
			</div>
		</form>
		<div style="text-align:center;padding:5px 0">
			<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">Submit</a>
		</div>
	</div>
</div>

</body>
<script type="text/javascript">
	$(function(){
		searchA();
	})
	function searchA(){
		var state = $('#state').val();
		var type = 0;
		var data = {
				type:type,
				state:state
		};
		var pager = $('#dg').datagrid({
			queryParams: data,
			//双击事件
			onDblClickRow :function(rowIndex,rowData){
					getSelected()
				}
		}).datagrid('getPager');	// get the pager of datagrid
		pager.pagination({
			buttons:[{
				iconCls:'icon-edit',
				handler:function(){
					getSelected();
				}
			}]
		});
		pager.pagination().find('a.l-btn').tooltip({
			content: function(){
				var cc = $(this).find('span.l-btn-icon').attr('class').split(' ');
				var icon = cc[1].split('-')[1];
				return icon + ' page';
			}
		});
		$('#approve').window('close');
		$('#addForm').window('close');
	}

	function getSelected(){
		var row = $('#dg').datagrid('getSelected');
		if (row){
			$('#approve').window('open');
			$('#update').form('load',{
				id:row.id,
				info:row.info,
				result:row.result
			});
		}
	}
	function submitForm(){
		var id = $('#id').val();
		var data = {
			id: id
		};
		$('#update').form('submit', {
			url: "/manage/complain/update",
			queryParams: data,
			onSubmit: function(){

			},
			success: function(data){
				var data = eval('(' + data + ')');
				if(data.code==10000){
					$.messager.alert('成功',"提交成功");
					var pager = $('#dg').datagrid('reload');
				}else{
					$.messager.alert('失败',data.code+"："+data.message);
				}

			},
			error: function(){
				$.messager.alert('失败',"联系管理员");
			}
		});
		$('#approve').window('close');
	}

	function deletedState( state ){
		if("0" == state){
			return "处理中";
		}else{
			return "已解决";
		}

	}
	</script>
</html>